package org.lanqiao.api.admin;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.lanqiao.common.Constants;
import org.lanqiao.common.JsonResult;
import org.lanqiao.common.JsonResultWriter;
import org.lanqiao.pojo.PageModel;
import org.lanqiao.service.AdminServiceImpl;


/**
 * 删除用户
 * Servlet implementation class UserDeleteServlet
 */
@WebServlet("/api/admin/UserDeleteServlet")
public class UserDeleteServlet extends HttpServlet {
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException{
		/**
		 * 获取参数
		 */
			String id=request.getParameter("userId");
			/**
			 * 调用删除用户方法
			 */
			AdminServiceImpl abc=new AdminServiceImpl();
			JsonResult result=null;
			try {
				int model=abc.deleteUsers(id);
				if(model>0){
					result=new JsonResult("删除成功",Constants.STATUS_SUCCESS);
				}else {
					result=new JsonResult("删除错误",Constants.STATUS_UNFOUND);
				}
			} catch (Exception e) {
				result=new JsonResult("删除异常",Constants.STATUS_FAILURE);
			}
			JsonResultWriter.writer(response, result);;
	}

}
